package co.laomag.coffee.controller.user;

import cn.hutool.core.date.DateUtil;
import co.laomag.coffee.api.user.UserApi;
import co.laomag.coffee.model.entity.ChUser;
import co.laomag.coffee.model.vo.Message;
import co.laomag.coffee.model.vo.Pagination;
import co.laomag.coffee.service.user.UserService;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 马泽朋
 * @version 1.0
 * @date 2020/4/19 下午 3:14
 */
@RestController
public class UserController implements UserApi {

    @Resource
    private UserService userService;

    @Override
    public Message addUser(ChUser chUser) {
        chUser.setCreatetime(DateUtil.date());
        chUser.setUpdatetime(DateUtil.date());
        Message message = userService.addUser(chUser);
        return message;
    }

    @Override
    public Message updateUser(ChUser chUser) {
        chUser.setUpdatetime(DateUtil.date());
        Message message = userService.updateUser(chUser);
        return message;
    }

    @Override
    public Message getUserList(Pagination pagination) {
        Message userList = userService.getUserList(pagination);
        return userList;
    }
}
